package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.common.domain.query.PageQuery;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 19311
 * @CreateTime: 2025-03-26
 * @Description: 管理端查询问题列表的相关接口
 * @Version: 1.0
 */
@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class AdminQuestionController {

    private final IInteractionQuestionService interactionQuestionService;

    @GetMapping("/page")
    public PageDTO getPage(QuestionAdminPageQuery questionAdminPageQuery) {
        return interactionQuestionService.getPage(questionAdminPageQuery);
    }

    /**
     * 管理端按id查询问题接口
     * @param id
     * @return QuestionVO
     */
    @GetMapping("/{id}")
    public QuestionAdminVO getById(@PathVariable Long id) {
        return interactionQuestionService.getQuestionAdminVo(id);
    }

    /**
     * 隐藏当前问题
     * @param id
     */
    @ApiOperation("设置隐藏")
    @PutMapping("/{id}/hidden/true")
    public void setHidden(@PathVariable Long id) {
        interactionQuestionService.hideAll(id);
    }

    /**
     * 显示当前问题
     * @param id
     */
    @ApiOperation("设置显示")
    @PutMapping("/{id}/hidden/false")
    public void setDisplay(@PathVariable Long id) {
        interactionQuestionService.displayAll(id);
    }
}
